﻿namespace NanoMvvm
{
    public class CommandSelectionViewModel<T> : SelectionViewModel<CommandViewModel<T>>
        where T : CommandBase
    {
        protected override SelectionItemViewModel<CommandViewModel<T>> CreateSelectionItem(CommandViewModel<T> item)
        {
            return new CommandSelectionItemViewModel<T>(this, item);
        }

        protected override void OnItemEnabled(SelectionItemViewModel<CommandViewModel<T>> holder)
        {
            base.OnItemEnabled(holder);

            holder.Item.Command.RaiseCanExecuteChanged();
        }

        protected override void OnItemDisabled(SelectionItemViewModel<CommandViewModel<T>> holder)
        {
            base.OnItemDisabled(holder);

            holder.Item.Command.RaiseCanExecuteChanged();
        }
    }
}